The IPropOwnerDrawSink Interface
The owner-draw
capabilities of the PropertyList control require
an object that implements this interface. This can be
done by adding the IPropOwnerDraw.tlb file to your
project through the References dialog, which is listed
under "Excalibur PropertyList Owner-draw Interface"
if the typelib has been registered,
and adding the following line to the General
Declarations section of a class module
or form:
Implements IPropOwnerDrawSink
You can then use the SetOwnerDrawSink method of the
PropertyList to enable owner-draw. Note that you
will see adverse effects in the control if you add
owner-draw items to it without setting the owner-draw
sink object.
The interface also provides facilities to use
your own control for the second column of
the property list when your owner-drawn item
is selected. This allows you to create items
that use more than the color dropdown, combo
box or textbox controls used in the built-in
item types.
All controls that you add for owner-draw should
be made children of the property list control.
IPropOwnerDrawSink Members
Certain
parameters mean the same thing for each
member of the interface. These parameters
are:
- sPropListName
The name you have given the property list
control that is calling this method.
- nIndex
The index of the item that the property
list is referring to in the method.
The members of this interface are as follows:
Sub PropCommitPending(sPropListName As String)
Occurs when a pending transaction in an
owner-drawn item needs to be committed.
A common action to take when this method
is called is to set the Value property of
the currently selected item.
Sub PropDrawItem(sPropListName As String, _
nIndex As Integer, _
bDrawActive As Boolean, _
DrawDC As Long, _
rctLeft As Long, rctTop As Long, _
rctRight As Long, rctBottom As Long)
Occurs when an owner-drawn item needs to
be repainted. You must paint both the left
and right columns of the item specified in
the nIndex parameter. Parameters are
as follows:
bDrawActive
If True, draw the item
in its selected state.
Otherwise, the item
should be drawn normally.
DrawDC
This is the handle to the
device context that you need
to draw on. This is not equal
to PropertyList1.hDC, because
the control uses a memory DC
to paint the list before
displaying it on the screen.
rctLeft
The position on the X plane
where the drawing should
begin in the first column.
rctTop
The position on the Y plane
where the drawing should
begin.
rctRight
The position on the X plane
where the drawing should
end in the second column.
rctBottom
The position on the Y plane
where the drawing should
end.
The X position where the first column ends
is equal to:
(PropertyList1.LongestItem \ Screen.TwipsPerPixelX) + 1
The X position where the second column begins
should be:
(PropertyList1.LongestItem \ Screen.TwipsPerPixelX) + 6
Sub PropHideCtrls(sPropListName As String)
This member is called when you need
to set the Visible property to
False for all controls that you
are using for owner-draw.
Sub PropPlaceCtrl(sPropListName As String, _
nIndex As Integer, _
rctLeft As Long, rctTop As Long, _
rctWidth As Long, rctHeight As Long)
Occurs when an owner-drawn item has been selected.
If you are using your own control for this item,
you should place it in this procedure using the
coordinates given. The caption and state of the
control should be set as well, and also made
visible. The control should be a child
of the property list.
Example code for the placement of a checkbox
follows. The checkbox is a child of the property
list control.
chkOD.Caption = PropertyList1.Value(nIndex)
If chkOD.Caption = "1 - Visible" Then
chkOD.Value = 1
Else
chkOD.Value = 0
End If
chkOD.Move rctLeft, rctTop, rctWidth, rctHeight
chkOD.Visible = True